package com.ruoyi.api.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.vo.AuthLogin;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzUsersync;
import com.ruoyi.system.service.IDzUsersyncService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 同步用户Controller
 * 
 * @author ruoyi
 * @date 2022-10-31
 */
@RestController
@RequestMapping("/api/usersync")
public class DzUsersyncApiController extends BaseController
{
    @Autowired
    private IDzUsersyncService dzUsersyncService;

    /**
     * 查询同步用户列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DzUsersync dzUsersync)
    {
        startPage();
        List<DzUsersync> list = dzUsersyncService.selectDzUsersyncListWeb(dzUsersync);
        return getDataTable(list);
    }

    /**
     * 导出同步用户列表
     */
    @Log(title = "同步用户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzUsersync dzUsersync)
    {
        List<DzUsersync> list = dzUsersyncService.selectDzUsersyncListWeb(dzUsersync);
        ExcelUtil<DzUsersync> util = new ExcelUtil<DzUsersync>(DzUsersync.class);
        util.exportExcel(response, list, "同步用户数据");
    }

    /**
     * 获取同步用户详细信息
     */
    @GetMapping(value = "/{yhId}")
    public AjaxResult getInfo(@PathVariable("yhId") Long yhId)
    {
        return AjaxResult.success(dzUsersyncService.selectDzUsersyncByYhId(yhId));
    }

    /**
     * 新增同步用户
     */
    @Log(title = "同步用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AuthLogin userLogin)
    {
        return toAjax(1);
    }

    /**
     * 修改同步用户
     */
    @Log(title = "同步用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzUsersync dzUsersync)
    {
        return toAjax(dzUsersyncService.updateDzUsersync(dzUsersync));
    }

    /**
     * 删除同步用户
     */
    @Log(title = "同步用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{yhIds}")
    public AjaxResult remove(@PathVariable Long[] yhIds)
    {
        return toAjax(dzUsersyncService.deleteDzUsersyncByYhIds(yhIds));
    }
}
